package com.ruoyi.web.controller.pacs;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.PacsStudy;
import com.ruoyi.system.service.IPacsStudyService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 检查Controller
 * 
 * @author ruoyi
 * @date 2025-03-09
 */
@RestController
@RequestMapping("/system/study")
public class PacsStudyController extends BaseController
{
    @Autowired
    private IPacsStudyService pacsStudyService;

    /**
     * 查询检查列表
     */
    @PreAuthorize("@ss.hasPermi('system:study:list')")
    @GetMapping("/list")
    public TableDataInfo list(PacsStudy pacsStudy)
    {
        startPage();
        List<PacsStudy> list = pacsStudyService.selectPacsStudyList(pacsStudy);
        return getDataTable(list);
    }

    /**
     * 导出检查列表
     */
    @PreAuthorize("@ss.hasPermi('system:study:export')")
    @Log(title = "检查", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PacsStudy pacsStudy)
    {
        List<PacsStudy> list = pacsStudyService.selectPacsStudyList(pacsStudy);
        ExcelUtil<PacsStudy> util = new ExcelUtil<PacsStudy>(PacsStudy.class);
        util.exportExcel(response, list, "检查数据");
    }

    /**
     * 获取检查详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:study:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(pacsStudyService.selectPacsStudyById(id));
    }

    /**
     * 新增检查
     */
    @PreAuthorize("@ss.hasPermi('system:study:add')")
    @Log(title = "检查", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PacsStudy pacsStudy)
    {
        return toAjax(pacsStudyService.insertPacsStudy(pacsStudy));
    }

    /**
     * 修改检查
     */
    @PreAuthorize("@ss.hasPermi('system:study:edit')")
    @Log(title = "检查", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PacsStudy pacsStudy)
    {
        return toAjax(pacsStudyService.updatePacsStudy(pacsStudy));
    }

    /**
     * 删除检查
     */
    @PreAuthorize("@ss.hasPermi('system:study:remove')")
    @Log(title = "检查", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(pacsStudyService.deletePacsStudyByIds(ids));
    }
}
